package com.karina.visualization.chart.client;

import java.util.ArrayList;
import java.util.List;

public class Gradient {

	public static class Entry {
		public Color color;
		public double radius;

		public Entry(Color color, double radius) {
			this.color = color;
			this.radius = radius;
		}
	}

	private final List<Entry> entries = new ArrayList<Gradient.Entry>();

	public Gradient(String... gradients) {
		for (String gradient : gradients) {
			String[] gt = gradient.split(",");
			String colors = gt[0].trim().substring(1);
			assert (colors.length() == 6);
			int r = Integer.parseInt(colors.substring(0, 2), 16);
			int g = Integer.parseInt(colors.substring(2, 4), 16);
			int b = Integer.parseInt(colors.substring(4, 6), 16);
			double radius = Double.parseDouble(gt[1].trim());

			addGraident(new Color(r, g, b, 1), radius);

		}
	}

	public List<Entry> getColroPattern() {
		return entries;
	}

	public void addGraident(Color color, double radious) {
		entries.add(new Entry(color, radious));
	}

}
